//
// Created by wujehy on 2020/8/23.
//


#ifndef MOSQUITTO_AUTH_PLUGIN_USERDB_H
#define MOSQUITTO_AUTH_PLUGIN_USERDB_H

#include <string>

namespace SQLite
{
    class Database;
}
class UserDB
{
    const std::string m_table_name = "UserDB";
    SQLite::Database *m_database = nullptr;
public:
//    struct UserDataType{
//        std::string username ;
//        std::string password ;
//        int64_t     Createat;
//        int64_t     ModifyAt;
//    };

    UserDB(SQLite::Database *mDatabase);

    void init();
    int add(const std::string &username , const std::string &password);
    int update(const std::string &username , const std::string &password );
    int del(const std::string &username );
    bool exist(const std::string &username , const std::string &password);
    int getPassword(const std::string &username , std::string &password);
    int creatTable();
};


#endif //MOSQUITTO_AUTH_PLUGIN_USERDB_H
